package com.jl.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jl.commons.result.PageDataInfo;
import com.jl.mapper.CycleTaskMapper;
import com.jl.model.CycleTask;
import com.jl.service.ICycleTaskService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 在此表中的数据会根据cron时间表达式插入到 inspection_task表中，形成巡检指令 服务实现类
 * </p>
 *
 * @author JiangJian
 * @since 2019-03-18
 */
@Service
public class CycleTaskServiceImpl extends ServiceImpl<CycleTaskMapper, CycleTask> implements ICycleTaskService {


    @Override
    public void selectCycleTaskDataGrid(PageDataInfo<Map<String, Object>> pageDataInfo, QueryWrapper<CycleTask> qw) {
        Page<Map<String,Object>> page = new Page<>();
        page.setSize(pageDataInfo.getSize());
        page.setCurrent(pageDataInfo.getCurrent());
        List<Map<String,Object>> mapList =baseMapper.selectDataGrid(page,qw);
        pageDataInfo.setTotal(page.getTotal());
        pageDataInfo.setRecords(mapList);
    }

    @Override
    public boolean isCycleTaskNameUsed(String name) {
        return baseMapper.selectCycleTaskNameCount(name)>0;
    }
}
